<?php
/**
 * Create By: PhpStorm
 * User: yihua
 * File: GetGoodsList.php
 * Date: 2017/2/12
 * Time: 16:38
 */
namespace app\home\model\page\goods;

use app\api\model\dao\Goods;
use app\library\Error;
use app\library\PageBase;
use think\Validate;

class GetGoodsList extends PageBase
{

    private $objGoods;

    public function __construct()
    {
        parent::__construct();
        $this->objGoods = new Goods();
    }


    public function excute($param)
    {
        $ret = $this->checkToken($param);
        if (false === $ret) {
            header('Location:/home/loginpage');
            return $this->getRes(Error::ERR_NO_AUTH);
        }
        $type = 'page';
        if (isset($param['type']) && $param['type'] == 'list') {
            $type = $param['type'];
        }
        $goodsInfo = $this->objGoods->getGoodsList($type);
        if ($goodsInfo === false) {
            return $this->getRes(Error::ERR_SYS);
        }
        $this->data = $goodsInfo;
        return $this->getRes();
        //$result['html_page'] = $goodsInfo->render();
        //$result['goodsListInfo'] = $goodsInfo->toArray();
        //$this->data = $goodsInfo;
        //var_dump($this->data);
        //return $this->getRes();;
    }
}
